import {LogLanguage} from "../dist/index.js"

// 测试冒号排除功能
const testCases = [
  // 冒号分隔的数值
  "erRelationmapper.insert:135",
  "Points Processor: 64)",
  "SBYBaseService:50)",
  "SBYBaseService: 87)",
  "SBYBaseService: 102)",
  "SBYBaseService: 127)",
  "SBYBaseService:139)",
  "SBYBaseService: 150)",
  "SBYBaseService:164)",
  "SBYBaseService: 70)",
  "SBYBaseService:179)",
  "SBYBaseService:181)",
  
  // 等号分隔的数值
  "reqId=70011754450582062",
  "merId=1749611201012113",
  "afterTaxAmt=6200008",
  "amt=62000",
  "accType=1",
  "funCode=7011",
  "funCode=7001",
  "reqId=700117544505",
  "reqId=70011754450",
  
  // 复杂日志行
  "2025-08-06 11:23:02,220 INFO [TID:] [fcdfba1a21214a8e97c7d8fd1a8aa287.1161.17544505317727189] points.PointsProcessor (com.cn.yft.ora.bank.p600030.points.PointsProcessor:64) - 【权益积分通道】 积分发放 reqId=70011754450582062 merId=1749611201012113"
]

console.log("=== 冒号排除测试 ===")

testCases.forEach((testCase, index) => {
  console.log(`\n测试 ${index + 1}:`)
  console.log(`输入: ${testCase}`)
  
  // 检查数值识别
  const numberRegex = /([:=])\s*(\d+)/g
  let match
  let foundNumbers = []
  
  while ((match = numberRegex.exec(testCase)) !== null) {
    const separator = match[1]  // : 或 =
    const number = match[2]     // 数字部分
    const fullMatch = match[0]  // 完整匹配
    const separatorLength = separator.length
    const spacesAfterSeparator = fullMatch.length - separatorLength - number.length
    const from = match.index + separatorLength + spacesAfterSeparator  // 跳过分隔符和空格
    const to = from + number.length  // 只包含数字
    
    foundNumbers.push({
      full: fullMatch,
      separator: separator,
      number: number,
      from: from,
      to: to,
      highlightedContent: testCase.slice(from, to)
    })
  }
  
  if (foundNumbers.length > 0) {
    console.log("✓ 数值识别成功:")
    foundNumbers.forEach(num => {
      console.log(`  - 完整匹配: "${num.full}"`)
      console.log(`  - 分隔符: "${num.separator}"`)
      console.log(`  - 数字: "${num.number}"`)
      console.log(`  - 高亮范围: ${num.from}-${num.to}`)
      console.log(`  - 高亮内容: "${num.highlightedContent}"`)
      console.log(`  - 分隔符排除: ${num.highlightedContent === num.number ? '✓' : '✗'}`)
      
      // 特别检查冒号
      if (num.separator === ':') {
        const hasColon = num.highlightedContent.includes(':')
        if (hasColon) {
          console.log(`  ✗ 错误: 冒号仍然被高亮 "${num.highlightedContent}"`)
        } else {
          console.log(`  ✓ 正确: 冒号已排除 "${num.highlightedContent}"`)
        }
      }
    })
  } else {
    console.log("✗ 未找到数值")
  }
})
